package com.citms.common;

/*
 *
 * 状态码封装类
 * 
 * @author denghq
 * @date 2018/10/29
 */
public class CodeMsg {
    private int code;
    private String codeRemark;

    private CodeMsg() {
    }

    private CodeMsg(int code, String codeRemark) {
        this.code = code;
        this.codeRemark = codeRemark;
    }

    //成功
    public static CodeMsg SUCCESS = new CodeMsg(0, "操作成功");

    //通用的错误码
    public static CodeMsg TOKEN_ERROR = new CodeMsg(5000, "Token错误");
    
    public static CodeMsg SYSTEM_ERROR  = new CodeMsg(10001, "系统错误");
    
    public static CodeMsg SERVER_RESOURCES_UNAVAILABLE = new CodeMsg(10002, "服务端资源不可用");
    
    public static CodeMsg REMOTE_SERVICE_ERROR = new CodeMsg(10003, "远程服务出错");
    
    public static CodeMsg PARAMETER_ERROR = new CodeMsg(10008, "参数错误，请参考API文档");
    
    public static CodeMsg BAD_REQUEST = new CodeMsg(10012, "非法请求");
    
    public static CodeMsg HTTPMETHD_NONSUPPORT = new CodeMsg(10021, "请求的HTTP METHOD不支持");

    //程序校验出错的状态码
    public static CodeMsg API_ABANDONED = new CodeMsg(10026, "该接口已经废弃"); 
    
    public static CodeMsg APIRESULT_FOMATTERERROR = new CodeMsg(10027, "接口返回值格式异常");
    
    public static CodeMsg API_UNAUTHORIZED = new CodeMsg(10028, "接口未授权");
   
    public static CodeMsg API_CALLERROR = new CodeMsg(10029, "接口调用异常");
    
    public static CodeMsg INSER_ERROR = new CodeMsg(10030, "新增出错");
    
    public static CodeMsg UPDATE_ERROR = new CodeMsg(10031, "更新出错");
    
    public static CodeMsg DELETE_ERROR = new CodeMsg(10032, "删除出错");
    
    public static CodeMsg QUERY_ERROR = new CodeMsg(10033, "查询出错");
    
    public static CodeMsg OTHER_ERROR = new CodeMsg(11000, "其它错误");
    
    public static CodeMsg LICENSE_ERROR = new CodeMsg(12000, "License授权错误");
    
    
    
    

    //业务出错状态码
    /**
     * code 规则如下：
     * web后台：51XYXX
     * 其中Y 表示 模块 Y值相同，则属于同一模块下
     */

    //*************************  web后台：51XYXX  ************************************/
    public static CodeMsg WEB_CODE_MSG_TEST = new CodeMsg(510101, "测试信息：%s");


   /* public CodeMsg fillArgs(Object... args) {
        int code = this.code;
        String message = String.format(this.codeRemark, args);
        return new CodeMsg(code, message);
    }*/

    public CodeMsg fillArgs(String args) {
        int code = this.code;
        return new CodeMsg(code, args);
    }
    
    @Override
    public String toString() {
        return "CodeMsg [code=" + code + ", codeRemark=" + codeRemark + "]";
    }

	public int getCode() {
		return code;
	}



	public String getCodeRemark() {
		return codeRemark;
	}
}
